    window.onload = function() {
        layui.use(['jquery', 'layer'], function() {
            var $ = layui.jquery,
            layer = layui.layer;
            $(".item.img").on("click",function(){
                var src = $(this).attr("src");
                var str = '<img src="'+src+'" style="display:block;margin:25px auto;width:750px;height:400px;"/>'
                Utils.layer.open({
                    type: 1,
                    title: false,
                    content: str,
                    area:['850px','450px'],
                    closeBtn: 2,
                })
            })
            
            //修改店铺logo
            var uploaderHeader = {
                'data': {
                    'token': '',
                    'uploadDomain': '',
                    'domain': ''
                },
                //  上传成功后的回调.
                'complete': function(res) {
                    // 这里只需要res.key
                    var url = "http://" + uploaderHeader.data.domain + "/" + res.key;
                    // console.log(url);
                    $('.user_img').attr('src', url);
                    $.ajax({
                        'type': 'POST',
                        'url': '/shop/modify-logo',
                        'data': {
                            logo: res.key
                        },
                        'dataType': 'json',
                        'success': function(data) {
                            Utils.layer.closeAll();
                            // location.reload() 
                            Utils.layer.msg(data.msg);
                        }

                    });
                },
                // 上传时的错误.
                'error': function() {
                    console.dir(arguments);
                },
                // 分片上传时的进度展示功能在此书写.
                'next': function(response) {
                    // var chunks = response.chunks || [];
                    // var total = response.total;
                },
                // 初始化获取token.
                'init': function() {
                    $.ajax({
                        'url': '/upload/get-token',
                        'type': 'POST',
                        'dataType': 'json',
                        'success': function(data) {
                            if (data.code != 200) {
                                Utils.layer.msg(data.msg);
                                return false;
                            }
                            uploaderHeader.data.token = data.data.token; // token
                            uploaderHeader.data.domain = data.data.domain; // 显示域名
                            // uploader.data.uploadDomain = 'idv093d.qiniudns.com';    // 上传域名
                            // console.log(uploader.data.domain)
                        }
                    });
                },
                'eventBind': function() {
                    this.init();
                    $('#logo').on('change', function() {
                        var token = uploaderHeader.data.token;
                        var config = {
                            useCdnDomain: true,
                            disableStatisticsReport: false,
                            region: qiniu.region.z0
                        };

                        var putExtra = {
                            fname: "",
                            params: {},
                            mimeType: ["image/png", "image/jpeg", "image/gif"], // 限制文件类型.
                        };

                        var file = this.files[0];
                        if (TestFileSuffix(file.name) < 0) {
                            layer.msg('请上传 jpg/png 类型图片');
                            return;
                        }
                        var observable;
                        if (file) {
                            var files = $("#logo")[0].files[0]; // 用来显示的文件名.需要修改,重名时覆盖
                            var key1 = file.name;
                            // var key = key1.split(".")[0] + randomNum() + "." + key1.split(".")[1];
                            var key = key1.split(".")[0] + "." + key1.split(".")[1];
                            putExtra.params["x:name"] = key.split(".")[0];
                            // 配置完成的数组.
                            var subObject = {
                                next: uploaderHeader.next,
                                error: uploaderHeader.error,
                                complete: uploaderHeader.complete
                            };
                            var subscription;
                            // 调用sdk上传接口获得相应的observable，控制上传和暂停
                            observable = qiniu.upload(files, key, token, putExtra, config);
                            subscription = observable.subscribe(subObject);
                            // subscription.unsubscribe();  // 取消上传.
                        }
                    });
                }
            };

            uploaderHeader.eventBind();
        })
}   